#!/usr/bin/env bb

(require '[babashka.deps :as deps])
(require '[clojure.java.io :as io])
(require '[cheshire.core :as json])

(deps/add-deps '{:deps {djblue/portal {:mvn/version "0.19.0"}}})

(require '[portal.api :as p])

(p/open)

(.addShutdownHook
 (Runtime/getRuntime)
 (Thread. (fn [] (p/close))))

(add-tap #'p/submit)

(doseq [line (line-seq (io/reader *in*))]
  (tap>
   (try
     (json/parse-string line true)
     (catch Exception _ex
       line))))
